### 封装自己的Response类，少写代码

from rest_framework.response import Response


class APIResponse(Response):
    def __init__(self, status=None, headers=None, **kwargs):
        data = {'code': 100, 'msg': '成功'}
        if kwargs:
            data.update(kwargs)

        super(APIResponse, self).__init__(data=data, status=status, headers=headers)



# APIResponse(code=999,msg='异常。。')
# APIResponse(token='sdasfdasdfas')
# APIResponse(username='lqz')
# Response({'code':100,'msg':'成功','data':[],use})